/*
 * Created by JFormDesigner on Fri Sep 17 16:03:35 CST 2021
 */

package com.minelx.woods.pc.form;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;

import com.intellij.uiDesigner.core.*;
import com.minelx.woods.pc.service.WoodsSession;

/**
 * @author aaa
 */
public class BootForm extends JFrame {
	static {
		try {
			UIManager.setLookAndFeel(new NimbusLookAndFeel());
		} catch (UnsupportedLookAndFeelException e) {
			throw new RuntimeException("something is wrong here", e);
		}
	}

	public static void main(String[] args) {
		new BootForm().setVisible(true);
	}

	private final WoodsSession session;

	public BootForm() {
		initComponents();

		LoginDialog loginDialog = new LoginDialog(this);
		loginDialog.setVisible(true);
		session = loginDialog.getSession();
	}

	private void postReviewButtonActionPerformed(ActionEvent e) {
		new PostReviewForm(session.reviewService()).setVisible(true);
	}

	private void viewReviewsButtonActionPerformed(ActionEvent e) {
		new ViewReviewsForm(session.reviewService(), session.taskService()).setVisible(true);
	}

	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
		dialogPane = new JPanel();
		contentPanel = new JPanel();
		label1 = new JLabel();
		panel1 = new JPanel();
		postReviewButton = new JButton();
		viewReviewsButton = new JButton();

		//======== this ========
		setTitle("\u5f15\u5bfc\u9875");
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		var contentPane = getContentPane();
		contentPane.setLayout(new BorderLayout());

		//======== dialogPane ========
		{
			dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
			dialogPane.setLayout(new BorderLayout());

			//======== contentPanel ========
			{
				contentPanel.setLayout(new BorderLayout());

				//---- label1 ----
				label1.setText("\u5f15\u5bfc");
				label1.setFont(new Font("Microsoft JhengHei Light", Font.PLAIN, 50));
				label1.setHorizontalAlignment(SwingConstants.CENTER);
				contentPanel.add(label1, BorderLayout.NORTH);

				//======== panel1 ========
				{
					panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));

					//---- postReviewButton ----
					postReviewButton.setText("\u63d0\u4ea4\u5ba1\u6838");
					postReviewButton.setFont(new Font("Microsoft JhengHei Light", Font.PLAIN, 24));
					postReviewButton.addActionListener(e -> postReviewButtonActionPerformed(e));
					panel1.add(postReviewButton, new GridConstraints(0, 0, 1, 1,
						GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
						GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
						GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
						null, null, null));

					//---- viewReviewsButton ----
					viewReviewsButton.setText("\u67e5\u770b\u5ba1\u6838");
					viewReviewsButton.setFont(new Font("Microsoft JhengHei Light", Font.PLAIN, 24));
					viewReviewsButton.addActionListener(e -> viewReviewsButtonActionPerformed(e));
					panel1.add(viewReviewsButton, new GridConstraints(1, 0, 1, 1,
						GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE,
						GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
						GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
						null, null, null));
				}
				contentPanel.add(panel1, BorderLayout.CENTER);
			}
			dialogPane.add(contentPanel, BorderLayout.CENTER);
		}
		contentPane.add(dialogPane, BorderLayout.CENTER);
		setSize(550, 420);
		setLocationRelativeTo(getOwner());
		// JFormDesigner - End of component initialization  //GEN-END:initComponents
	}

	// JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
	private JPanel dialogPane;
	private JPanel contentPanel;
	private JLabel label1;
	private JPanel panel1;
	private JButton postReviewButton;
	private JButton viewReviewsButton;
	// JFormDesigner - End of variables declaration  //GEN-END:variables
}
